from Day1.Caculator import Cal
import unittest


class TestCal(unittest.TestCase):
    # def setUp(self):
    #     #环境准备或者数据准备,或者建立连接
    #     print('##########Start############')
    #
    # def test_add_01(self):
    #     self.cal = Cal(2,3)
    #     self.assertEqual(self.cal.sum(), 5)
    #     print('This is test case 01')
    #
    # def test_div_01(self):
    #     self.cal = Cal(10,2)
    #     self.assertEqual(self.cal.div(),5)
    #     print('This is test case 02')
    #
    # def test_div_02(self):
    #     self.cal = Cal(10,0)
    #     self.assertEqual(self.cal.div(),'分母不能为0.')
    #     print('This is test case 03')
    #
    # def tearDown(self):
    #     #清理数据, 还原测试环境
    #     print('##########End############')
    @classmethod
    def setUpClass(cls):
        # 环境准备或者数据准备,或者建立连接
        print('##########Start############')

    @unittest.expectedFailure
    def test_add_01(self):
        self.cal = Cal(2, 3)
        self.assertEqual(self.cal.sum(), 5)
        print('This is test case 01')

    def test_div_01(self):
        self.cal = Cal(10, 2)
        self.assertEqual(self.cal.div(), 4)
        print('This is test case 02')

    def test_div_02(self):
        self.cal = Cal(10, 0)
        self.assertEqual(self.cal.div(), '分母不能为0.')
        print('This is test case 03')

    @classmethod
    def tearDownClass(cls):
        # 清理数据, 还原测试环境
        print('##########End############')


if __name__ == '__main__':
    # unittestdemo.main()
    r = unittest.TestResult()
    TestCal('test_add_01').run(result=r)
    print(r.__dict__)
